import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;

/**
 * Classe representant un Ovale ou un Cercle a dessiner
 * @author Simon Castro
 *
 */
public class Ovale extends AbstractForme{
	private int rayonH;
	private int rayonV;
	private int nseq;
	
	/**
	 * 
	 * @param x
	 * @param y
	 * @param rH
	 * @param rV
	 * @param nseq
	 */
	public Ovale(int rH, int rV, int nseq){
		this.rayonH = rH;
		this.rayonV = rV;
		this.nseq = nseq;
	}
		
	public int getRayonH(){
		return this.rayonH;
	}
	
	public int getRayonV(){
		return this.rayonV;
	}
	
	//pour les tris
	public float getAire(){
		return (float)(this.rayonH * this.rayonV) / 2;
	}

	@Override
	void draw(Graphics g, int x, int y) {
		
		//differencier un cercle d'un ovale
		if(rayonH == rayonV)
			g.setColor(Color.BLUE);
		else
			g.setColor(Color.RED);
		
		g.fillOval(x, y, rayonH, rayonV);
		
		//Bordure rectangulaire
		g.setColor(Color.GRAY);
		((Graphics2D) g).setStroke(new BasicStroke(LARGEUR_P, DECO_P, COIN_P, 
	            LIMITE_P, PATTERN_P, DEBUT_P));
		((Graphics2D) g).drawRect(x, y, rayonH, rayonV);
	}
	
	public int getNseq(){
		return this.nseq;
	}

	/*
	 * (non-Javadoc)
	 * @see AbstractForme#getCodeType()
	 */
	int getCodeType() {
		int code;
		
		if(rayonH == rayonV)
			code = 3;
		else
			code = 4;
		
		return code;
	}

	/*
	 * (non-Javadoc)
	 * @see AbstractForme#getDistanceMax()
	 */
	int getDistanceMax() {
		
		if(rayonH > rayonV)
			return rayonH;
		else
			return rayonV;
	}
}
